#import "RNFavoritesDetailHeader.h"
#import "RNConstants.h"

@interface RNFavoritesDetailHeader (RNFavoritesDetailHeaderPrivateMethods)
-(void)bindControllerWithEntityName_:(NSString *)entityName withPredicate:(NSPredicate *)thePredicate inManagedObjectContext:(NSManagedObjectContext *)moc;
@end

@implementation RNFavoritesDetailHeader

+(NSArray *)arrayOfHeadersWithRootObject:(id)rootObject filteredWithObject:(id)filterObject inManagedObjectContext:(NSManagedObjectContext *)moc {
    RNFavoritesDetailHeader *header = [[RNFavoritesDetailHeader alloc] initWithRootObject:nil];
    [header setHeaderHeight:RNEmptyHeaderHeight];
    [header bindControllerWithEntityName_:RNEntityNameItem withPredicate:[NSPredicate predicateWithFormat:@"favorite == YES"] inManagedObjectContext:moc];
    return [NSArray arrayWithObject:header];
}

-(void)bindControllerWithEntityName_:(NSString *)entityName withPredicate:(NSPredicate *)thePredicate inManagedObjectContext:(NSManagedObjectContext *)moc {
    NSArrayController *controller = [self primaryController];
    [controller setEntityName:entityName];
    [controller setAutomaticallyRearrangesObjects:YES];
    [controller setManagedObjectContext:moc];
    [controller setFilterPredicate:thePredicate];
    [controller prepareContent];
    [self setPrimaryController:controller];
}

@end
